package com.bao.work.other;

public class Monster {
    public String name;
    public int life;
    public int attack;

    public Monster() {
    }

    public Monster(String name, int life, int attack) {
        this.name = name;
        this.life = life;
        this.attack = attack;
    }
    public void hit(Monster monster){
        monster.life-=this.attack;
    }
    public void move(){
        System.out.println("怪物移动");
    }
    public void lifeUp(){
        this.life=this.life<10?this.life+20:this.life+10;
    }
}
class Snake extends Monster{
    public Snake() {
    }

    public Snake(String name, int life, int attack) {
        super(name, life, attack);
    }

    @Override
    public void move() {
        System.out.println("大蛇S走位");
    }

    @Override
    public void lifeUp() {
        System.out.print("大蛇回复");
        super.lifeUp();
    }

    @Override
    public void hit(Monster monster) {
        System.out.println("大蛇攻击");
        super.hit(monster);
    }
}
class Centipede extends Monster{
    public Centipede() {
    }

    public Centipede(String name, int life, int attack) {
        super(name, life, attack);
    }
    @Override
    public void move() {
        System.out.println("飞天蜈蚣");
    }

    @Override
    public void lifeUp() {
        System.out.print("蜈蚣回复");
        super.lifeUp();
    }

    @Override
    public void hit(Monster monster) {
        System.out.println("蜈蚣攻击");
        super.hit(monster);
    }
}
